#!/usr/bin/env python
# -*- coding: utf-8 -*-

from abc import ABC, abstractmethod
from typing import Dict, List, Any, Optional
from dataclasses import dataclass
import logging


class ArticleData:
    """
    文章数据模型
    简单的数据结构，包含发布文章所需的基本字段
    """
    
    def __init__(self, title: str = "", content: str = "", url: str = ""):
        """
        初始化文章数据
        :param title: 文章标题
        :param content: 文章内容（HTML格式）
        :param url: 原始文章URL
        """
        self.title = title
        self.content = content
        self.url = url
        self.images: List[str] = []  # 图片URL列表
        self.local_images: List[str] = []  # 本地图片路径列表
        self.category_id: Optional[int] = None  # 分类ID
        self.tags: List[str] = []  # 标签列表
        self.status: str = "draft"  # 文章状态：draft, publish, future等
        self.featured_media_id: Optional[int] = None  # 特色图片ID
        self.publish_date: Optional[str] = None  # 定时发布时间
        self.extra_data: dict = {}  # 额外数据，用于存储特定平台需要的额外字段
    
    def to_dict(self) -> dict:
        """
        转换为字典格式
        :return: 文章数据字典
        """
        return {
            'title': self.title,
            'content': self.content,
            'url': self.url,
            'images': self.images,
            'local_images': self.local_images,
            'category_id': self.category_id,
            'tags': self.tags,
            'status': self.status,
            'featured_media_id': self.featured_media_id,
            'publish_date': self.publish_date,
            'extra_data': self.extra_data
        }
    
    def __str__(self) -> str:
        """字符串表示"""
        return f"ArticleData(title='{self.title}', url='{self.url}')"